<div class="style-block" style="background: {{settings.bg_color6}};">
   <div class="product" >
     <div class="product-wrap">
       <div class="photo fl">
         
         {% unless settings.order_button %}<img class="big-transparent" src="{{ 'big-ban.png' | asset_url }}" style="{% if product.available != false %}display: none;{% endif %}" />        {% endunless %} 
         <a href="{{product.first_image.original_url}}"  {% if product.images.size > 1 %}
         onClick="$('.gallery a[href$=\''+$(this).attr('href')+'\']').click(); return false;" 
       {% else %} rel="shadowbox[images];options={continuous:true};player=img;" 
       {% endif %} class="img big-img" title="{{product.title}}">
           <img src="{{product.first_image.medium_url}}" alt="" class="big-image" />
         </a>
         {% if product.images.size > 1 %}
         <div class="gallery">
           {% for image in product.images %}
           <a href="{{image.original_url}}" 
           class="{% cycle '','','','side' %}" 
           style="background: url({{image.small_url}}) center center no-repeat {{settings.bg_color3}};" 
           rel="shadowbox[images];options={continuous:true};player=img;"           
           data-img="{{ image.medium_url }}"           
           title="{{ product.title | escape }}">
           </a>
           {% endfor %}	
         </div>
         {% endif %}
         
         
         {% comment %}{% if account.enable_comparison? %}
      <!--<input type="checkbox" name="compare{{product.id}}" value="0" class="add_to_compare" rel="{{ product.id }}" />-->
         <div class="clear"><a href="#" class="add_to_compare" rel="{{ product.id }}">Сравнить</a></div>     
         {% endif %}{% endcomment %}
       </div>
       <div class="fl product-info">
         <h1 class="title">{{product.title}}</h1>
        {% if product.properties.size > 0 or product.variants.first.sku %}
         <table class="params">
           {% if product.variants.first.sku  %}  <tr>
             <td>Артикул</td>
             <td> <span id="sku-field">{{product.variants.first.sku}}</span>
             </td>
           </tr>	{% endif %}
           {% for property in product.properties %}
           <tr>
             <td>{{property.name}}</td>
             <td> {% for characteristic in property.characteristics %}   
               {{characteristic.name}}{% unless forloop.last %},{% endunless %} 
               {% endfor %}
             </td>
           </tr>	
           {% endfor %}
         </table>
         {% endif %}
         <form action="{{ cart_url }}" method="post" id="order">
           {% if product.show_variants? %}
           <div class="variants">		
             <select name="variant_id" id="variant-select">
               {% for variant in product.variants %}
               <option value="{{ variant.id }}">{{ variant.title | escape }}</option>
               {% endfor %}
             </select>
           </div>
           {% else %}
           <input type="hidden" name="variant_id" value="{{ product.variants.first.id }}" />
           {% endif %}
           {% if product.old_price %}<span class="old-price" id="old-field">{{product.old_price | money}}</span>{% endif %}
           
           <div class="buyzone quantity">
             <span class="price fl" id="price-field">{{product.sale_price | money}}</span>
             <span class="fl">&times;</span>
                 <span class="arrows fl">        
             <input type="text" disabled="disabled" data-price="{{product.sale_price}}" class="quantity_input qwt" value="1" />
             
               <span class="plus"></span>
               <span class="minus"></span>
             </span> 
             <input type="hidden" name="quantity" class="quantity_input_form qwt2" value="1" />
             <span class="fl">=</span>
             <span class="price fl" id="total-price">{{product.sale_price | money}}</span>
           </div>
           
           {% if product.available == false and product.similar_products.size > 0 %}
           <p><a href="#similar">посмотреть похожие товары</a></p>
           {% endif %}
           <input class="buy buy_button add_button" type="submit" value="Купить" />
           {% if product.prices.size > 0 %}
           <input type="hidden" value="price-kinds" name="price_kinds" />
           {% endif %}
         </form>
         <div id="price-list"></div>
         
         
       </div>
     </div>
     <div class="clear"></div>
     {% if product.description %}
     <div class="description editor-content">
       <h2>Описание</h2>
       {{product.description}}
     </div>
     {% endif %}
     {% if collection.products.size > 1 %}  
     <div class="prods-paginate">
       <a href="{% if collection.previous_product.url %}{{ collection.previous_product.url }}{% else %}{{ collection.products.last.url }}{% endif %}" class="fl"><span class="prev">〈</span>предыдущий товар</a>
       <a href="{% if collection.next_product.url %}{{ collection.next_product.url }} {% else %}{{ collection.products.first.url }}{% endif %}" class="fr">следующий товар<span class="next">〉</span></a>
     </div>
     {% endif %}   
     {% if product.related_products.size > 0 %}
     <div class="related_prods">
       <h2>Сопутствующие товары</h2>
     {% for product in product.related_products %}
     {% include 'product_block' %}
     {% endfor %}
     </div>
     {% endif %}
     
     {% if product.similar_products.size > 0 %}
     <div class="related_prods" id="similar">
       <h2>Аналогичные товары</h2>
     {% for product in product.similar_products %}
     {% include 'product_block' %}
     {% endfor %}
     </div>
     {% endif %}
     
     {% if account.reviews_enabled? %}
     {% include 'reviews' %}
     {% endif %}
   </div>
</div>
<script type="text/javascript">
   $(function() {
      
      {% if product.available == false %}
        {% if settings.order_button %}
         $('.add_button').addClass('order_button').val('ПОД ЗАКАЗ');      // set add-to-cart button to unavailable class  
          {% else %}  
         $('.add_button').addClass('disabled');      // set add-to-cart button to unavailable class
         $('.add_button').attr('disabled', 'disabled');  // disable add-to-cart button
         $('.big-transparent').show();
           {% endif %}
         $('#presence').html("Распродано");  
        
      {% endif %}
        var selectCallback = function(variant, selector) {          
           if (variant && variant.available == true) {
               // selected a valid variant
                $('.big-transparent').hide();
             {% if settings.order_button %}
               $('.add_button').removeClass('order_button').val('КУПИТЬ');      // set add-to-cart button to unavailable class  
               {% else %}
                $('.add_button').removeClass('disabled'); // remove unavailable class from add-to-cart button
                $('.add_button').removeAttr('disabled');      // reenable add-to-cart button
              {% endif %}
                
                {% if product.prices.size > 0 %}
                  var cost = calculate_total_cost(product, variant, $('.qwt').val());
                  $('#price-field').html(InSales.formatMoney(cost/$('.qwt').val(), "{{money_with_currency_format}}"));  // update price field
                  $('#total-price').html(InSales.formatMoney(cost, "{{money_with_currency_format}}"));  // update price field
                 $('.quantity_input').attr('data-price', cost/$('.qwt').val());  
                  {% else %} 
                $('#price-field').html(InSales.formatMoney(variant.price, "{{money_with_currency_format}}"));  // update price field
                $('.quantity_input').attr('data-price', variant.price);  
                   {% endif %}  
                $('#old-field').html(InSales.formatMoney(variant.old_price, "{{money_with_currency_format}}"));  // update old_price field
                $('#sku-field').html(variant.sku);  // update sku field
                $('#presence').html('');  // update presence field
           } else {
             //$('.big-transparent').show();
               // variant doesn't exist
              {% if settings.order_button %}
               $('.add_button').addClass('order_button').val('ПОД ЗАКАЗ');      // set add-to-cart button to unavailable class  
               {% else %}
                $('.add_button').addClass('disabled');      // set add-to-cart button to unavailable class
                $('.add_button').attr('disabled', 'disabled');  // disable add-to-cart button      
              {% endif %}            
                
                  if(variant){
                    //$('.big-transparent').show();
                     $('#presence').html("Распродано"); // update presence field message
                     {% if product.prices.size > 0 %}
                  var cost = calculate_total_cost(product, variant, $('.qwt').val());
                      $('#price-field').html(InSales.formatMoney(cost/$('.qwt').val(), "{{money_with_currency_format}}"));  // update price field
                  $('#total-price').html(InSales.formatMoney(cost, "{{money_with_currency_format}}"));  // update price field
                 $('.quantity_input').attr('data-price', cost/$('.qwt').val());  
                  {% else %} 
                $('#price-field').html(InSales.formatMoney(variant.price, "{{money_with_currency_format}}"));  // update price field
                $('.quantity_input').attr('data-price', variant.price);  
                   {% endif %}  
                     $('#old-field').html(InSales.formatMoney(variant.old_price, "{{money_with_currency_format}}"));  // update old_price field
                     $('#sku-field').html(variant.sku);  // update sku field
                 } else {
                   //$('.big-transparent').show(); 
                     $('#presence').html(''); // update presence field message
                     $('#price-field').html("Модификация отсутствует"); 
                   
                     //$('#price-field').html('');  // clear price field
                     $('#old-field').html('');  // clear old_price field
                     $('#sku-field').html('');  // clear sku field
                 }
           }
          recalcAmount($('.plus'));
        };
        var product = {{product | json}};
        var selector = new InSales.OptionSelectors('variant-select', { product: {{product | json}}, onVariantSelected: selectCallback, filterOptionValues: true }); 
       
                {% if product.prices.size > 0 %}
        $('.qwt2').bind('change', function() {
            
            var quantity = parseInt($(this).val());
          
            var variant = product.variants.length == 1 ? product.variants[0] : selector.getCurrVariant();
            var cost = calculate_total_cost(product, variant, quantity);
          
          $('#price-field').html(InSales.formatMoney(cost/quantity, "{{money_with_currency_format}}"));
          $('#total-price').html(InSales.formatMoney(cost, "{{money_with_currency_format}}"));
        });
       
        {% endif %}
   });
</script>